package com.qg.lizhanqi.videosquare.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qg.lizhanqi.videosquare.R;


public class MyFragment extends Fragment {
    final String LOGININFO = "loginInfo";
    private View myView;
    private TextView tv_name;
    private TextView tv_phone;
    private SharedPreferences sharedPreferences;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        myView = inflater.inflate(R.layout.fragment_my, container, false);
        return myView;
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if(sharedPreferences ==null){
            sharedPreferences = getActivity().getSharedPreferences(LOGININFO, Context.MODE_PRIVATE);
        }
        String userphone = sharedPreferences.getString("userphone","");
        String username = sharedPreferences.getString("username","");
        initView(myView);
        tv_name.setText(username);
        tv_phone.setText(userphone);
    }
    private void initView(View myView) {
        tv_name = (TextView) myView.findViewById(R.id.tv_name);
        tv_phone = (TextView) myView.findViewById(R.id.tv_phone);
    }
}
